{% load staticfiles %}
{% csrf_token %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div style="width: 600px;margin: 0 auto">
    <div>
        <h3>调用支付接口</h3>
        <a href="#" order_id='1' status="1" class="oper_btn">去付款</a></td>
        <div id="qrcode" style="width: 250px;height: 250px;background-color: white;margin: 100px auto;"></div>
    </div>
</div>
<script src="http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
    <script>
        $('.oper_btn').click(function () {
            console.log('1')
           //获取status订单状态
           status=$(this).attr('status');
           if(status ==1){
               //进行支付
               //获取订单id
               order_id = $(this).attr('order_id');
               csrf = $('input[name="csrfmiddlewaretoken"]').val();
               //组织参数
               params = {"order_id":order_id,"csrfmiddlewaretoken":csrf};
               //发起ajax post请求，访问/order/pay，传递参数：order_id
               $.post('/pay/',params,function (data) {
                   if(data.res == 3){
                       //引导用户到支付页面
                       // $('#qrcode').empty().qrcode({text: data.pay_url});
                       window.open(data.pay_url)
                   }else{
                       alart(data.errmsg)
                   }
               })
           }else{
               //其他情况
           }
        });
    </script>

</body>
</html>